package com.kikidao.app.testclasses.useraccounts;

import com.datalayer.annotations.Attribute;
import com.datalayer.annotations.Constraint;
import com.datalayer.annotations.Direction;
import com.datalayer.annotations.Entity;

/**
 * Created with IntelliJ IDEA.
 * User: Georgiana.Scarlat
 * Date: 7/23/12
 * Time: 2:54 PM
 */
@SuppressWarnings("UnusedDeclaration")
@Entity(tableName = "ACCOUNTS")
public class Account {
    private int id, code;
    private String type;

    public Account() {
    }

    public Account(int code, int id, String type) {
        this.code = code;
        this.id = id;
        this.type = type;
    }

    @Direction("get")
    @Attribute(fieldName = "code", attributeName = "PRIVILEGES", type = "int")
    public int getCode() {
        return code;
    }

    @Direction("set")
    @Attribute(fieldName = "code", attributeName = "PRIVILEGES", type = "int")
    public void setCode(int code) {
        this.code = code;
    }

    @Direction("get")
    @Constraint(constraintName = "primary key")
    @Attribute(fieldName = "id", attributeName = "ACCOUNT_ID", type = "int")
    public int getId() {
        return id;
    }

    @Direction("set")
    @Constraint(constraintName = "primary key")
    @Attribute(fieldName = "id", attributeName = "ACCOUNT_ID", type = "int")
    public void setId(int id) {
        this.id = id;
    }

    @Direction("get")
    @Attribute(fieldName = "type", attributeName = "ACCOUNT_TYPE", type = "varchar(20)")
    public String getType() {
        return type;
    }

    @Direction("set")
    @Attribute(fieldName = "type", attributeName = "ACCOUNT_TYPE", type = "varchar(20)")
    public void setType(String type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Account account = (Account) o;

        return code == account.code && id == account.id && !(type != null ? !type.equals(account.type) : account.type != null);

    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + code;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Account{" +
                "code=" + code +
                ", id=" + id +
                ", type='" + type + '\'' +
                '}';
    }
}
